import React, { useEffect, useState } from 'react'
import type { MenuProps } from 'antd';
import homeinfo from './homeinfo.module.css'
import { searchRoute } from "@/utils/util";
import { AppstoreOutlined, MailOutlined, SettingOutlined, ProfileOutlined, HomeOutlined, GlobalOutlined, SolutionOutlined, PhoneOutlined, AuditOutlined, ExperimentOutlined } from '@ant-design/icons';
import { Menu } from 'antd';
import { CheckCircleTwoTone, HeartTwoTone, SmileTwoTone } from '@ant-design/icons';
import { NavLink, useRoutes, useLocation, useParams, useSearchParams, useNavigate } from 'react-router-dom'
import {
    Outlet
} from 'react-router-dom';
const Homeview = (props) => {
    const { state } = useLocation()
    const navigate = useNavigate()
    console.log(state);
    const items = [
        {
            label: '新闻动态',
            key: '/homeinfo/NewsCenter',
            icon: <GlobalOutlined />,
        },
        {
            label: '车祸案例',
            key: '/homeinfo/Expeanimal',
            icon: <ExperimentOutlined />,
        },
        {
            label: '安全案例',
            key: '/homeinfo/Entculture',
            icon: <AppstoreOutlined />,
        },
        {
            label: '预警记录',
            key: '/homeinfo/Relatedmechan',
            icon: <AuditOutlined />,
        },
        {
            label: '车检记录',
            key: '/homeinfo/Personrecrui',
            icon: <SolutionOutlined />,
        },
        {
            label: '联系我们',
            key: '/homeinfo/Connectus',
            icon: <PhoneOutlined />,
        },
    ];
    var homeinfopath = state.name;
    var homeinfocolumn = homeinfopath;
    const rouerpath = () => {
        return (<div>
            <span className={homeinfo.backhome} onClick={() => {
                navigate('/home')
            }}></span>
            <span>{homeinfopath}</span>
        </div>)
    }
    if (homeinfopath == '简介' || homeinfopath == '行业动态') {
        homeinfocolumn = rouerpath()
    }
    console.log("ssssssssssssssssss", homeinfopath);
    useEffect(() => {
    }, [])
    const clickMenu = (key) => {
        const route = searchRoute(items.key, items);
        var a = items.filter(v => v.key == key.key)
        var b = a.map(v => v.label)[0];
        navigate(key.key, {
            replace: false,
            state: {
                name: b
            }
        });
    };
    return (
        <div className={homeinfo.loaction}>
            <div className={homeinfo.content1} >
                <div className={homeinfo.rightbox}>
                    <div className={homeinfo.righttopbox}>
                        {homeinfocolumn}
                    </div>
                    <div className={homeinfo.righttopboxinfo}>
                        <Outlet />
                    </div>
                </div>
                <div className={homeinfo.leftbox}>
                    <div className={homeinfo.lefttopbox}>
                    </div>
                    <div>
                        <div className={homeinfo.logobox}>
                        </div>
                        <Menu mode="inline" items={items} defaultSelectedKeys={['3']} onClick={clickMenu}>
                        </Menu>
                    </div>
                </div>
            </div>
        </div>
    )
}
export default Homeview